package pnlBeheer;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.*;
import tblLSListner.TMLSLConsumptie;
import tblModelDrank.TMADrank;
import tblModelDrank.TMDrank;
import tblModelDrank.TMRDrank;
import tblModelGerecht.*;
import cbModel.*;
import controllerCon.*;

public class PnlGDBeheer extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1457359604857133716L;
	
		public JPanel pnlTblCon;
		public JTable tblCon;
		public JScrollPane scrollCon;
	
		public JLabel lblTitle;
		public JLabel lblCon;
		public JLabel lblCat;
		public JLabel lblOldNumber;
		public JLabel lblNumber;
		public JLabel lblName;
		public JLabel lblPrice;
		public JLabel lblDiscr;
        public JLabel lblSort;

        public JTextField txtOldNumber;
        public JTextField txtNewNumber;
		public JTextField txtName;
		public JTextField txtPrice;
		public JTextField txtDiscr;
                
		public JComboBox<?> boxMenu;
		public JComboBox<?> boxCat;
		public JComboBox<?> boxCon;
                
		public ImageIcon imgSave;
		public ImageIcon imgUpdate;
		public ImageIcon imgFind;
		public ImageIcon imgDelete;
	
		public JButton btnsaveNew;
		public JButton btnsaveOld;
		public JButton btndelete;
		
		public ConBtnSave cbs;
		public ConBtnUpdate cbu;
		public ConBtnDelete cbd;
	
		public MenuCbUpdate mcu;
		public ConCbUpdate ccu;
		
		public CBMMenu cbmm;
		public CBMCategorie cbmc;
		
		public TMGerecht tmg;
		public TMDrank tmd;
		public TMRGerecht tmrg;
		public TMAGerecht tmag;
		public TMRDrank tmrd;
		public TMADrank tmad;
		
		public TMLSLConsumptie tmlslc;
	
		
		public PnlGDBeheer(){
		
			this.cbs = new ConBtnSave(this);
			this.cbu = new ConBtnUpdate(this);
			this.cbd = new ConBtnDelete(this);
			
			this.mcu  = new MenuCbUpdate(this);
			this.ccu  = new ConCbUpdate(this);
			
			this.cbmc = new CBMCategorie(this);
			this.cbmm = new CBMMenu(this);
			
			this.tmg = new TMGerecht(this);
			this.tmd = new TMDrank(this);
			
			this.tmrg = new  TMRGerecht(this);
			this.tmag = new  TMAGerecht(this);
			this.tmrd = new  TMRDrank(this);
			this.tmad = new  TMADrank(this);
			
			this.tmlslc = new TMLSLConsumptie(this);
			
			setBackground(Color.white);
			setVisible(true);
			setLayout(null);
			
			lblTitle = new JLabel("<html><h1><b>Consumtie beheer</b></h1></html>");
			lblTitle.setBounds(50, 50, 300, 40);
			add(lblTitle);
			
			lblCon = new JLabel("Menu");
			lblCon.setBounds(50, 150, 100, 20);
			add(lblCon);
			
			lblCat = new JLabel("Categorie");
			lblCat.setBounds(50, 200, 100, 20);
			add(lblCat);
			
			lblCon = new JLabel("Consumtie");
			lblCon.setBounds(50,250,100,20);
			add(lblCon);
			
			lblOldNumber = new JLabel("Nummer");
			lblOldNumber.setBounds(50, 290, 100, 20);
			add(lblOldNumber);
			
			lblNumber = new JLabel("New Nummer");
			lblNumber.setBounds(50, 330, 100, 20);
			add(lblNumber);
			
			lblName = new JLabel("Naam");
			lblName.setBounds(50, 370, 100, 20);
			add(lblName);
			
			lblPrice = new JLabel("Prijs");
			lblPrice.setBounds(50, 410, 100, 20);
			add(lblPrice);
			
			lblDiscr = new JLabel("Beschrijving");
			lblDiscr.setBounds(50, 450, 100, 20);
			add(lblDiscr);
			
            lblSort = new JLabel("<html><h3><b>Sorteer lijst op categorie : </b></h3></html>");
            lblSort.setBounds(600,30,200,20);
            add(lblSort);
                        
			boxMenu = new JComboBox<>(cbmm);
			boxMenu.setSelectedIndex(0);
			boxMenu.addItemListener(mcu);
            boxMenu.setBounds(150, 150, 200, 20);
			add(boxMenu);
			
			boxCat = new JComboBox<>(cbmc);
            boxCat.setSelectedIndex(0);
			boxCat.setBounds(150, 200, 200, 20);
			add(boxCat);
			
			String [] consumtie = {"Gerecht","Drank"};
			boxCon = new JComboBox<>(consumtie);
			boxCon.setBounds(150, 250, 200, 20);
			boxCon.addItemListener(ccu);
			add(boxCon);
			
			pnlTblCon = new JPanel();
			pnlTblCon.setLayout(new BorderLayout());
			pnlTblCon.setBounds(600, 80, 700, 580);
			add(pnlTblCon);
			
			tblCon = new JTable();
			tblCon.setBounds(0,0,600,0);
			tblCon.getSelectionModel().addListSelectionListener(tmlslc);
			tblCon.setModel(tmg);
			
			scrollCon = new JScrollPane(tblCon);
			pnlTblCon.add(scrollCon);
			
			txtOldNumber = new JTextField();
			txtOldNumber.setBounds(150, 290, 200, 20);
			txtOldNumber.setEditable(false);
			add(txtOldNumber);
			
			txtNewNumber = new JTextField();
			txtNewNumber.setBounds(150, 330, 200, 20);
			add(txtNewNumber);
			
			txtName = new JTextField();
			txtName.setBounds(150, 370, 200, 20);
			add(txtName);
			
			txtPrice = new JTextField();
			txtPrice.setBounds(150, 410, 200, 20);
			add(txtPrice);
			
			txtDiscr = new JTextField();
			txtDiscr.setBounds(150, 450, 200, 20);
			add(txtDiscr);
			
			
			imgSave = new ImageIcon(getClass().getResource("/image/save.gif"));
			btnsaveNew = new JButton("Save",imgSave);
			btnsaveNew.setHorizontalTextPosition(JButton.CENTER);
			btnsaveNew.setVerticalTextPosition(JButton.BOTTOM);
			btnsaveNew.setBounds(30, 500, 100, 90);
			btnsaveNew.setOpaque(false);
			btnsaveNew.setContentAreaFilled(false);
			btnsaveNew.setBorderPainted(false);
			btnsaveNew.setFocusPainted(false);
			btnsaveNew.addActionListener(cbs);
			btnsaveNew.setActionCommand("Save");
			add(btnsaveNew);
			
			
			imgUpdate = new ImageIcon(getClass().getResource("/image/update.gif"));
			btnsaveOld = new JButton("Update",imgUpdate);
			btnsaveOld.setHorizontalTextPosition(JButton.CENTER);
			btnsaveOld.setVerticalTextPosition(JButton.BOTTOM);
			btnsaveOld.setBounds(110, 500, 100, 90);
			btnsaveOld.setOpaque(false);
			btnsaveOld.setContentAreaFilled(false);
			btnsaveOld.setBorderPainted(false);
			btnsaveOld.setFocusPainted(false);
			btnsaveOld.addActionListener(cbu);
			btnsaveOld.setActionCommand("Update");
			add(btnsaveOld);
			
			
			imgDelete = new ImageIcon(getClass().getResource("/image/trash.gif"));
			btndelete = new JButton("Delete",imgDelete);
			btndelete.setHorizontalTextPosition(JButton.CENTER);
			btndelete.setVerticalTextPosition(JButton.BOTTOM);
			btndelete.setBounds(190, 500, 100, 90);
			btndelete.setOpaque(false);
			btndelete.setContentAreaFilled(false);
			btndelete.setBorderPainted(false);
			btndelete.setFocusPainted(false);
			btndelete.addActionListener(cbd);
			btndelete.setActionCommand("Delete");		
			add(btndelete);
			}
		
		public JComboBox<?> getBoxMenu()     {return boxMenu;}
		public JComboBox<?> getBoxCat()      {return boxCat;}
		public JComboBox<?> getBoxCon()      {return boxCon;}
		public JTextField   getTxtNewNumber(){return txtNewNumber;}
		public JTextField   getTxtOldNumber(){return txtOldNumber;}
		public JTextField   getTxtName()     {return txtName;}
		public JTextField   getTxtPrice()    {return txtPrice;}
		public JTextField   getTxtDiscr()    {return txtDiscr;}
		public JScrollPane	getScrollCon()   {return scrollCon;}
		public JPanel		getPnlTblCon()   {return pnlTblCon;}
        public JTable       gettblCon()      {return tblCon;}
        
	}	